In a known valve-actuating mechanism of this type (EP-A-342,007), two coupling pins butting against one another are provided in the bores of the rocker arms and can be displaced counter to a spring force, by an electromagnet arranged in one of the rocker arms, in such a way that they bridge the separating gaps between adjacent rocker arms and thus connect all the rocker arms rigidly to one another, so that the rocker arms acting on the valves are now moved by the second rocker arms according to the cam contour of the second cams. One problem in this construction is that the coupling pins have to be positioned very accurately, in order to ensure that the first two rocker arms can move freely in the uncoupled position. Furthermore, accommodating an electromagnet, by means of which the necessary short switching times of approximately 5 ms can be achieved, in the rocker arm presents considerable problems as do the dissipation of the heat generated and the current supply. Finally, in the event of repair, the valve drive has to be at least partially dismantled.